<?php
// +----------------------------------------------------------------------
// | 幕小铺
// +----------------------------------------------------------------------
// | 版权所有 2016~2020 幕小铺科技（大连）有限公司
// +----------------------------------------------------------------------
// | 2020/03/14
// +----------------------------------------------------------------------

namespace app\video\datacache;

use think\facade\Cache;

/**
 * 预置评论推送 缓存层
 * @package app\user_center\model
 */
class VideoPlayCommentartificial{
	/**
     * 缓存视频上传时间
     * @param cache 是否更新 缓存
	 * @param  int $play_id  视频id
     * @author shiqiang
     * @return array
     */
    public function getPushPlayCreateTimePlayId($play_id, $cache = false){
        $cacheName = 'push_play_create_time_play_id'.$play_id;
		
        if(!Cache::get($cacheName) || $cache){
			$map = [];
			$map[] = ['id', '=', $play_id];
			$map[] = ['play_status', '=', 1];
			$map[] = ['play_operation_status', '=', 1];
			$video_play = model('VideoPlay') -> where($map) -> find();
			if(isset($video_play['create_time'])){
				Cache::set($cacheName, $video_play['create_time']);
			}
        }
        return Cache::get($cacheName);
	}
	
	private $map_mobile = [
			['mobile', '>=', 14490000001],
			['mobile', '<=', 14499999999]
		];
	
	/**
     * 预置用户缓存
     * @param cache 是否更新 缓存
	 * @param  int $play_id  视频id
     * @author shiqiang
     * @return array
     */
    public function getPushUserMoblie($cache = false){
        $cacheName = 'get_push_artificial_user_id';
		
        if(!Cache::get($cacheName) || $cache){
			$user_id = model('user_center/UcMemberMobile', 'model\user') -> where($this -> map_mobile) -> column('uid');//获取uid
			Cache::set($cacheName, $user_id);
        }
        return Cache::get($cacheName);
	}
}
